home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / lynx-2.4 / WWW / Library / Implementation / HTAnchor.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-28  |  10.0 KB  |  333 lines

  1. /*                 /Net/dxcern/userd/timbl/hypertext/WWW/Library/Implementation/HTAnchor.html
  2.  */
  3.  
  4. /*      Hypertext "Anchor" Object                                    HTAnchor.h
  5. **      ==========================
  6. **
  7. **      An anchor represents a region of a hypertext document which is linked
  8. **      to another anchor in the same or a different document.
  9. */
  10.  
  11. #ifndef HTANCHOR_H
  12. #define HTANCHOR_H
  13.  
  14. /* Version 0 (TBL) written in Objective-C for the NeXT browser */
  15. /* Version 1 of 24-Oct-1991 (JFG), written in C, browser-independant */
  16.  
  17. #include "HTList.h"
  18. #include "HTAtom.h"
  19.  
  20. #ifdef SHORT_NAMES
  21. #define HTAnchor_findChild                      HTAnFiCh
  22. #define HTAnchor_findChildAndLink               HTAnFiLi
  23. #define HTAnchor_findAddress                    HTAnFiAd
  24. #define HTAnchor_delete                         HTAnDele
  25. #define HTAnchor_makeLastChild                  HTAnMaLa
  26. #define HTAnchor_parent                         HTAnPare
  27. #define HTAnchor_setDocument                    HTAnSeDo
  28. #define HTAnchor_document                       HTAnDocu
  29. #define HTAnchor_setFormat                      HTAnSeFo
  30. #define HTAnchor_format                         HTAnForm
  31. #define HTAnchor_setIndex                       HTAnSeIn
  32. #define HTAnchor_setPrompt                      HTAnSePr
  33. #define HTAnchor_isIndex                        HTAnIsIn
  34. #define HTAnchor_address                        HTAnAddr
  35. #define HTAnchor_hasChildren                    HTAnHaCh
  36. #define HTAnchor_title                          HTAnTitl
  37. #define HTAnchor_setTitle                       HTAnSeTi
  38. #define HTAnchor_appendTitle                    HTAnApTi
  39. #define HTAnchor_link                           HTAnLink
  40. #define HTAnchor_followMainLink                 HTAnFoMa
  41. #define HTAnchor_followTypedLink                HTAnFoTy
  42. #define HTAnchor_makeMainLink                   HTAnMaMa
  43. #define HTAnchor_setProtocol                    HTAnSePr
  44. #define HTAnchor_protocol                       HTAnProt
  45. #define HTAnchor_physical                       HTAnPhys
  46. #define HTAnchor_setPhysical                    HTAnSePh
  47. #define HTAnchor_methods                        HtAnMeth
  48. #endif
  49.  
  50. /*                      Main definition of anchor
  51. **                      =========================
  52. */
  53.  
  54. typedef struct _HyperDoc HyperDoc;  /* Ready for forward references */
  55. typedef struct _HTAnchor HTAnchor;
  56. typedef struct _HTParentAnchor HTParentAnchor;
  57.  
  58. /*      After definition of HTFormat: */
  59. #include "HTFormat.h"
  60.  
  61. typedef HTAtom HTLinkType;
  62.  
  63. typedef struct {
  64.   HTAnchor *    dest;           /* The anchor to which this leads */
  65.   HTLinkType *  type;           /* Semantics of this link */
  66. } HTLink;
  67.  
  68. struct _HTAnchor {              /* Generic anchor : just links */
  69.   HTLink        mainLink;       /* Main (or default) destination of this */
  70.   HTList *      links;          /* List of extra links from this, if any */
  71.   /* We separate the first link from the others to avoid too many small mallocs
  72.      involved by a list creation. Most anchors only point to one place. */
  73.   HTParentAnchor * parent;      /* Parent of this anchor (self for adults) */
  74. };
  75.  
  76. struct _HTParentAnchor {
  77.   /* Common part from the generic anchor structure */
  78.   HTLink        mainLink;       /* Main (or default) destination of this */
  79.   HTList *      links;          /* List of extra links from this, if any */
  80.   HTParentAnchor * parent;      /* Parent of this anchor (self) */
  81.  
  82.   /* ParentAnchor-specific information */
  83.   HTList *      children;       /* Subanchors of this, if any */
  84.   HTList *      sources;        /* List of anchors pointing to this, if any */
  85.   HyperDoc *    document;       /* The document within which this is an anchor */
  86.   char *        address;        /* Absolute address of this node */
  87.   char *    post_data;      /* posting data */
  88.   char *     post_content_type;  /* type of post data */
  89.   HTFormat      format;         /* Pointer to node format descriptor */
  90.   BOOL          isIndex;        /* Acceptance of a keyword search */
  91.   char *        isIndexAction;  /* URL of isIndex server */
  92.   char *        isIndexPrompt;  /* Prompt for isIndex query */
  93.   char *        title;          /* Title of document */
  94.   char *        owner;          /* Owner of document */
  95.  
  96.   HTList*       methods;        /* Methods available as HTAtoms */
  97.   void *        protocol;       /* Protocol object */
  98.   char *        physical;       /* Physical address */
  99.   BOOL          underway;       /* Document about to be attached to it */
  100.   BOOL        isISMAPScript;    /* Script for clickable image map */
  101. };
  102.  
  103. typedef struct {
  104.   /* Common part from the generic anchor structure */
  105.   HTLink        mainLink;       /* Main (or default) destination of this */
  106.   HTList *      links;          /* List of extra links from this, if any */
  107.   HTParentAnchor * parent;      /* Parent of this anchor */
  108.  
  109.   /* ChildAnchor-specific information */
  110.   char *        tag;            /* Address of this anchor relative to parent */
  111. } HTChildAnchor;
  112.  
  113.  
  114. /* DocAddress structure is used for loading an absolute anchor with all
  115.  * needed information including posting data and post content type.
  116.  */
  117.  
  118. typedef struct _DocAddress {
  119.     char * address;
  120.     char * post_data;
  121.     char * post_content_type;
  122. } DocAddress;
  123.  
  124. /*      Create new or find old sub-anchor
  125. **      ---------------------------------
  126. **
  127. **      This one is for a new anchor being edited into an existing
  128. **      document. The parent anchor must already exist.
  129. */
  130.  
  131. extern HTChildAnchor * HTAnchor_findChild
  132.   PARAMS(
  133.      (HTParentAnchor *parent,
  134.       CONST char *tag)
  135.   );
  136.  
  137. /*      Create or find a child anchor with a possible link
  138. **      --------------------------------------------------
  139. **
  140. **      Create new anchor with a given parent and possibly
  141. **      a name, and possibly a link to a _relatively_ named anchor.
  142. **      (Code originally in ParseHTML.h)
  143. */
  144. extern HTChildAnchor * HTAnchor_findChildAndLink
  145.   PARAMS((
  146.       HTParentAnchor * parent,  /* May not be 0 */
  147.       CONST char * tag,         /* May be "" or 0 */
  148.       CONST char * href,        /* May be "" or 0 */
  149.       HTLinkType * ltype        /* May be 0 */
  150.   ));
  151.  
  152.  
  153. /*      Create new or find old named anchor
  154. **      -----------------------------------
  155. **
  156. **      This one is for a reference which is found in a document, and might
  157. **      not be already loaded.
  158. **      Note: You are not guaranteed a new anchor -- you might get an old one,
  159. **      like with fonts.
  160. */
  161.  
  162. extern HTAnchor * HTAnchor_findAddress PARAMS((CONST DocAddress * address));
  163.  
  164.  
  165. /*      Delete an anchor and possibly related things (auto garbage collection)
  166. **      --------------------------------------------
  167. **
  168. **      The anchor is only deleted if the corresponding document is not loaded.
  169. **      All outgoing links from parent and children are deleted, and this anchor
  170. **      is removed from the sources list of all its targets.
  171. **      We also try to delete the targets whose documents are not loaded.
  172. **      If this anchor's source list is empty, we delete it and its children.
  173. */
  174.  
  175. extern BOOL HTAnchor_delete
  176.   PARAMS(
  177.      (HTParentAnchor *me)
  178.      );
  179.  
  180.  
  181. /*              Move an anchor to the head of the list of its siblings
  182. **              ------------------------------------------------------
  183. **
  184. **      This is to ensure that an anchor which might have already existed
  185. **      is put in the correct order as we load the document.
  186. */
  187.  
  188. extern void HTAnchor_makeLastChild
  189.   PARAMS(
  190.      (HTChildAnchor *me)
  191.      );
  192.  
  193. /*      Data access functions
  194. **      ---------------------
  195. */
  196.  
  197. extern HTParentAnchor * HTAnchor_parent
  198.   PARAMS(
  199.      (HTAnchor *me)
  200.      );
  201.  
  202. extern void HTAnchor_setDocument
  203.   PARAMS(
  204.      (HTParentAnchor *me, HyperDoc *doc)
  205.      );
  206.  
  207. extern HyperDoc * HTAnchor_document
  208.   PARAMS(
  209.      (HTParentAnchor *me)
  210.      );
  211. /* We don't want code to change an address after anchor creation... yet ?
  212. extern void HTAnchor_setAddress
  213.   PARAMS(
  214.      (HTAnchor *me, char *addr)
  215.      );
  216. */
  217.  
  218. /*      Returns the full URI of the anchor, child or parent
  219. **      as a malloc'd string to be freed by the caller.
  220. */
  221. extern char * HTAnchor_address
  222.   PARAMS(
  223.      (HTAnchor *me)
  224.      );
  225.  
  226. extern void HTAnchor_setFormat
  227.   PARAMS(
  228.      (HTParentAnchor *me, HTFormat form)
  229.      );
  230.  
  231. extern HTFormat HTAnchor_format
  232.   PARAMS(
  233.      (HTParentAnchor *me)
  234.      );
  235.  
  236. extern void HTAnchor_setIndex
  237.   PARAMS( (HTParentAnchor *me, char * address ) );
  238.  
  239. extern void HTAnchor_setPrompt
  240.   PARAMS( (HTParentAnchor *me, char * prompt ) );
  241.  
  242. extern BOOL HTAnchor_isIndex
  243.   PARAMS(
  244.      (HTParentAnchor *me)
  245.      );
  246.  
  247. extern BOOL HTAnchor_hasChildren
  248.   PARAMS(
  249.      (HTParentAnchor *me)
  250.      );
  251.  
  252. /*      Title handling
  253. */
  254. extern CONST char * HTAnchor_title
  255.   PARAMS(
  256.      (HTParentAnchor *me)
  257.      );
  258.  
  259. extern void HTAnchor_setTitle
  260.   PARAMS(
  261.      (HTParentAnchor *me, CONST char * title)
  262.      );
  263.  
  264. extern void HTAnchor_appendTitle
  265.   PARAMS(
  266.      (HTParentAnchor *me, CONST char * title)
  267.      );
  268.  
  269. /*      Owner handling
  270. */
  271. extern CONST char * HTAnchor_owner
  272.   PARAMS(
  273.      (HTParentAnchor *me)
  274.      );
  275.  
  276. extern void HTAnchor_setOwner
  277.   PARAMS(
  278.      (HTParentAnchor *me, CONST char * owner)
  279.      );
  280.  
  281. /*      Link this Anchor to another given one
  282. **      -------------------------------------
  283. */
  284.  
  285. extern BOOL HTAnchor_link
  286.   PARAMS(
  287.      (HTAnchor *source, HTAnchor *destination, HTLinkType *type)
  288.      );
  289.  
  290. /*      Manipulation of links
  291. **      ---------------------
  292. */
  293.  
  294. extern HTAnchor * HTAnchor_followMainLink
  295.   PARAMS(
  296.      (HTAnchor *me)
  297.      );
  298.  
  299. extern HTAnchor * HTAnchor_followTypedLink
  300.   PARAMS(
  301.      (HTAnchor *me, HTLinkType *type)
  302.      );
  303.  
  304. extern BOOL HTAnchor_makeMainLink
  305.   PARAMS(
  306.      (HTAnchor *me, HTLink *movingLink)
  307.      );
  308.  
  309. /*      Read and write methods
  310. **      ----------------------
  311. */
  312. extern HTList * HTAnchor_methods PARAMS((HTParentAnchor *me));
  313.  
  314. /*      Protocol
  315. **      --------
  316. */
  317. extern void * HTAnchor_protocol PARAMS((HTParentAnchor * me));
  318. extern void HTAnchor_setProtocol PARAMS((HTParentAnchor * me,
  319.                                         void* protocol));
  320.  
  321. /*      Physical address
  322. **      ----------------
  323. */
  324. extern char * HTAnchor_physical PARAMS((HTParentAnchor * me));
  325. extern void HTAnchor_setPhysical PARAMS((HTParentAnchor * me,
  326.                                         char * protocol));
  327.  
  328. #endif /* HTANCHOR_H */
  329.  
  330. /*
  331.  
  332.     */
  333.